package com.qf.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @ClassName myInterceptor
 * @Description TODO
 * @Author 86181
 * @Date 2022/9/6 17:12
 * @Version 1.0
 **/
public class myInterceptor implements HandlerInterceptor {
    //拦截目标前执行
    //类似前置通知
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("interceptor的pre方法执行了");
        return true;
    }
    //在目标方法之后,响应之前执行,类似于后置通知after-returning
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        System.out.println("interceptor的post方法执行了");
    }
    //响应完成之后执行类型after最终通知
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        System.out.println("interceptor的after方法执行了");
    }
}
